{% extends "base_master.html" %}



{% block include %}
<link rel="stylesheet" href="/resources/css/sheet.css" type="text/css" />
<script type="text/javascript" src="/resources/3th/jquery-jquery-ui-269fcfb/ui/jquery.ui.autocomplete.js"></script>
{% endblock %}


{% block script %}
$(document).ready(function(){


	$("button").click(function(){
		$("form").submit();
		
	}).button({
		icons:{"primary":"ui-icon-disk"}
	});
	

	$("#label").html($("#id_super_code option:selected").text());
		
	$("#complete").autocomplete({
		source:function(req, add){
			$.getJSON("/code/select/", req, function(data){
				
				add($.map(data, function(item){
					return{
						label:"(" + item.code + ")" + item.label,
						code:item.code
					};
				}));
				
			});
		},
		focus:function(e, ui){
		},
		//define select handler
		select: function(e, ui) {
			
			$("#label").children().remove();
			$("#label").html( ui.item.label);
			
			$("input[name='foo']").val(ui.item.code);
			
			//create formatted friend
			},
			//define select handler
			change: function() {
			}
	});
}); // end of ready
{% endblock %}

{%block body %}
<div>
	<h3>Code Details</h3>
</div>

<form  method="post">
	<div>
		<fieldset>
			<legend>기본정보</legend>
			
			<ul class="inputFieldList">
				{{form.non_field_errors}}
				<div class="fieldWrapper">
					<li>{{form.house_code.errors}} {{form.house_code.label}}</li>
					<li>
						{{form.house_code}}
					</li>
				</div>
				
				
				<div class="fieldWrapper">
					<li>
						{{form.code.errors}}
						<label for="id_code" >{{form.code.label}}</label>
					</li>
					<li>
						{{form.code}}
					</li>
				</div>
				
				
				<div class="fieldWrapper">
					<li>{{form.description.errors}} {{form.description.label}}</li>
					<li>
						{{form.description}}
					</li>
				</div>
				
				
				<div class="fieldWrapper">
					<li>{{form.used.errors}} {{form.used.label}}</li>
					<li>
						{{form.used}}
					</li>
				</div>
				<div class="fieldWrapper">
					<li>{{form.sort_seq.errors}} {{form.sort_seq.label}}</li>
					<li>
						{{form.sort_seq}}
					</li>
				</div>
				
				<div class="fieldWrapper">
					<li>{{form.memo.errors}} {{form.memo.label}}</li>
					<li>
						{{form.memo}}
					</li>
				</div>
				
				
			</ul>
		</fieldset>
		<fieldset>
			<legend>관련코드정보</legend>
			<ul>
				
				<li>상위코드</li>
				<li>{{form.super_code}}
				</li>
				<li>
					<input type="text"id="complete" />
					<div id="label" ></div>
					{{form.foo}}
				</li>
				
			</ul>
		</fieldset>
		
		<button type="button">저장</button>
		
	</div>
</form>	
{% endblock %}
